package com.atguigu.array;

public class Rectangle {//矩形，长方形
    //实例变量，私有化
    private double length;//长
    private double width;//宽

    //构造器
    public Rectangle() {
    }

    public Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }
    //get/set

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    //求面积
    public double area(){
        return length * width;
    }

    //求周长
    public double perimeter(){
        return 2 * (length + width);
    }

    //获取矩形对象的信息
    public String getInfo(){
        return "长：" + length + "，宽：" + width +"，面积：" + area() +"，周长：" + perimeter();
    }

}
